<!DOCTYPE html>
<html>
<head>
	<title>修改密码</title>
</head>
<link rel="stylesheet"
	href="../assets/bootstrap-table/bootstrap.min.css">
<link rel="stylesheet"
	href="../assets/bootstrap-table/bootstrap-table.css">
<link rel="stylesheet"
	href="../assets/bootstrap-table/bootstrap-editable.css">
<link rel="stylesheet"
	href="../css/style.css">
<script src="../assets/bootstrap-table/jquery.min.js"></script>
<script src="../assets/bootstrap-table/bootstrap.min.js"></script>
<script src="../assets/bootstrap-table/bootstrap-table.js"></script>
<script src="../assets/bootstrap-table/bootstrap-table-export.js"></script>
<script src="../assets/bootstrap-table/tableExport.js"></script>
<script src="../assets/bootstrap-table/bootstrap-table-editable.js"></script>
<script src="../assets/bootstrap-table/bootstrap-editable.js"></script>
<script src="../js/bootstrap-table-zh-CN.min.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/json2/20140204/json2.min.js"></script>
<![endif]-->
<script src="../js/util.js"></script>
<style type="text/css">
	.margintop{
		margin-top: 50px;
	}
</style>
<body>
<div id="info"></div>
<div class="modal show margintop" id="modifyPassword" tabindex="-1" role="dialog"
	aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<h3 class="modal-title" id="tagName">修改密码</h3>
			</div>

			<form id="hotSearchData" class="form-horizontal">
				<div class="modal-body">
					<div class="form-group">
						<label for="oldPassword" class="col-sm-2 control-label">原密码:</label>
						<div class="col-sm-8">
							<input type="password" class="form-control" name="oldPassword" id="oldPassword" placeholder="请输入原密码">
						</div>
					</div>

					<div class="form-group">
						<label for="newPassword" class="col-sm-2 control-label">新密码:</label>
						<div class="col-sm-8">
							<input type="password" class="form-control" name="newPassword" id="newPassword" placeholder="请输入新密码"/>
						</div>
					</div>

					<div class="form-group">
						<label for="confirmPassword" class="col-sm-2 control-label">确认密码:</label>
						<div class="col-sm-8">
							<input type="password" class="form-control" name="confirmPassword" id="confirmPassword" placeholder="请重新输入" />
						</div>
					</div>
				</div>
				<div class="modal-footer">
				    <span id="message" style="float:left"></span>
					<button type="button" id="updatePassword" class="btn btn-primary">提交更改</button>
				</div>	
			</form>
		</div>
	</div>
</div>
<script type="text/javascript">
	$campusId=getCookie('campusId');
    $campusAdmin=getCookie('campusAdmin');
	$(function(){
		$('#updatePassword').on('click',function(){
         var oldPassword=$('#oldPassword').val();
         var newPassword=$('#newPassword').val();
         var confirmPassword=$('#confirmPassword').val();

         if(newPassword.length<8){
         	$('#message').css('color','red').text("新密码不能少于八位");
         	return;
         }
         if(newPassword!=confirmPassword){
			$('#message').css('color','red').text("两次输入的密码不相同");
         }else{
         	$.post(
 			  "../campus/updateCampusAdminPassword?campusId="+$campusId,
 			  {oldPassword:oldPassword,newPassword:newPassword,campusAdmin:$campusAdmin,server:"56846a8a2fee49d14901d39cc48b8b2a"},
 			  function(data){
 			  	console.log(data);
 			  	 if(data.status=="success"){
 			  	 	$('#message').text(data.message);
 			  	 	$('#oldPassword').val("");
 			  	 	$('#newPassword').val("");
 			  	 	$('#confirmPassword').val("");
 			  	 }else{
 			  	 	$('#message').css('color','red').text(data.message);
 			  	 }
 			  },'json'
         	);
         }
		});
        
	});
</script>
</body>
</html>